<div class="grid_9">
<?php if(isset($system_message)): ?>
	<? echo $system_message ; ?>
<?php endif; ?>
	<?
		$formAttrib = array('id' => 'update_student', 'class' => 'admin-form');
		$submitButtonAttrib = array('name'=>'submit','value'=>'update profile');
		
	?>
    <div class="inner-border">
		<h6>Profile</b></h6>
		<noscript>
			<div class="error">Browser has detected you have disabled javascript, please enable javascript to continue</div>
		</noscript>
		<div class="profile-view">
<?if(!empty($db_entries)):?>
			<?php foreach($db_entries as $db_entry): ?>
			<?
				// form values
				$firstname = 	  set_value('firstname') == FALSE ? 	 $db_entry->firstname : set_value('firstname');
				$middlename = 	  set_value('middlename') == FALSE ? 	 $db_entry->middlename : set_value('middlename');
				$lastname = 	  set_value('lastname') == FALSE ? 		 $db_entry->lastname : set_value('lastname');
				$gender = 		  set_select('gender') == FALSE ? 		 $db_entry->gender : set_select('gender');
				$civilstatus =    set_value('civilstatus') == FALSE ? 	 $db_entry->civilstatus : set_value('civilstatus');
				$age = 			  set_value('age') == FALSE ? 			 $db_entry->age : set_value('age');
				$dob = 			  set_value('dob') == FALSE ? 			 $db_entry->dob : set_value('dob');
				$pob = 			  set_value('pob') == FALSE ? 			 $db_entry->pob : set_value('pob');
				$disability = 	  set_value('disability') == FALSE ? 	 $db_entry->disability : set_value('disability');
				$nationality = 	  set_value('nationality') == FALSE ? 	 $db_entry->nationality : set_value('nationality');
				$religion = 	  set_value('religion') == FALSE ? 		 $db_entry->religion : set_value('religion');
				$contactnumber =  set_value('contactnumber') == FALSE ?	 $db_entry->contactnumber : set_value('contactnumber');
				$email = 		  set_value('email') == FALSE 	?		 $db_entry->email : set_value('email');
				$presentaddress = set_value('presentaddress') == FALSE ? $db_entry->presentaddress : set_value('presentaddress');
				
				$eschoolname = 	  set_value('eschoolname') == FALSE ? 	 $db_entry->eschoolname : set_value('eschoolname');
				$eschooladdress = set_value('eschooladdress') == FALSE ? $db_entry->eschooladdress : set_value('eschooladdress');
				$eyeargraduate =  set_value('eyeargraduate') == FALSE ?  prep_data($db_entry->eyeargraduate) : set_value('eyeargraduate');
				
				$sschoolname = 	  set_value('sschoolname') == FALSE ? 	 $db_entry->sschoolname : set_value('sschoolname');
				$sschooladdress = set_value('sschooladdress') == FALSE ? $db_entry->sschooladdress : set_value('sschooladdress');
				$syeargraduate =  set_value('syeargraduate') == FALSE ?  prep_data($db_entry->syeargraduate) : set_value('syeargraduate');
				
				$vschoolname = 	  set_value('vschoolname') == FALSE ? 	 $db_entry->vschoolname : set_value('vschoolname');
				$vschooladdress = set_value('vschooladdress') == FALSE ? $db_entry->vschooladdress : set_value('vschooladdress');
				$vyeargraduate =  set_value('vyeargraduate') == FALSE ?  prep_data($db_entry->vyeargraduate) : set_value('vyeargraduate');				

				$oschoolname = 	  set_value('oschoolname') == FALSE ? 	 $db_entry->oschoolname : set_value('oschoolname');
				$oschooladdress = set_value('oschooladdress') == FALSE ? $db_entry->oschooladdress : set_value('oschooladdress');
				$oyeargraduate =  set_value('oyeargraduate') == FALSE ?  prep_data($db_entry->oyeargraduate) : set_value('oyeargraduate');
				
				$tschoolname =    set_value('tschoolname') == FALSE ? 	 $db_entry->tschoolname : set_value('tschoolname');
				$tschooladdress = set_value('tschooladdress') == FALSE ? $db_entry->tschooladdress : set_value('tschooladdress');
				$tyeargraduate =  set_value('tyeargraduate') == FALSE ?  prep_data($db_entry->tyeargraduate) : set_value('tyeargraduate');	
				
				$fathername = 	  	set_value('fathername') == FALSE ?	  $db_entry->fathername : set_value('fathername');			
				$fathercontact =  	set_value('fathercontact') == FALSE ? $db_entry->fathercontact : set_value('fathercontact');			
				$fatheroccupation = set_value('fatheroccupation') == FALSE ? $db_entry->fatheroccupation: set_value('fatheroccupation');	
				$mothername = 	    set_value('mothername') == FALSE ? 		 $db_entry->mothername : set_value('mothername');			
				$mothercontact = 	set_value('mothercontact') == FALSE ? 	 $db_entry->mothercontact : set_value('mothercontact');			
				$motheroccupation = set_value('motheroccupation') == FALSE ? $db_entry->motheroccupation: set_value('motheroccupation');
				$parentaddress = 	set_value('parentaddress') == FALSE ? 	 $db_entry->parentaddress : set_value('parentaddress');
						
				$nameofguardian  = 	set_value('guardianname') 	 == FALSE ? $db_entry->guardianname 	: set_value('guardianname');			
				$guardiancontact = 	set_value('guardiancontact') == FALSE ? $db_entry->guardiancontact 	: set_value('guardiancontact');			
				$guardianaddress = 	set_value('guardianaddress') == FALSE ? $db_entry->guardianaddress	: set_value('guardianaddress');
				
				
				
				/* set input attributes */
				
				$firstnameAttrib = 		array('name' => 'firstname', 	 'value' => $firstname, 	'id' => 'firstname');
				$middlenameAttrib = 	array('name' => 'middlename', 	 'value' => $middlename, 	'id' => 'middlename');
				$lastnameAttrib = 		array('name' => 'lastname', 	 'value' => $lastname, 		'id' => 'lastname');
				$ageAttrib = 			array('name' => 'age', 			 'value' => $age, 			'id' => 'fee_name');
				$dobAttrib = 			array('name' => 'dob', 	 		 'value' => $dob, 			'id' => 'fee_name');
				$pobAttrib = 			array('name' => 'pob', 			 'value' => $pob, 			'id' => 'fee_name');
				$disabilityAttrib = 	array('name' => 'disablity', 	 'value' => $disability, 	'id' => 'fee_name');
				$nationalityAttrib = 	array('name' => 'nationality', 	 'value' => $nationality, 	'id' => 'fee_name');
				$religionAttrib = 		array('name' => 'religion', 	 'value' => $religion, 		'id' => 'fee_name');
				$contactnumberAttrib = 	array('name' => 'contactnumber', 'value' => $contactnumber, 'id' => 'fee_name');
				$emailAttrib = 			array('name' => 'email', 		 'value' => $email, 		'id' => 'fee_name');
				$presentaddressAttrib = array('name' => 'presentaddress','value' => $presentaddress,'id' => 'fee_name');
				
				$esnAttrib =	array('name' => 'eschoolname', 		'value' => $eschoolname, 	'id' => 'fee_name');
				$esaAttrib = 	array('name' => 'eschooladdress', 	'value' => $eschooladdress, 'id' => 'fee_name');
				$eygAttrib = 	array('name' => 'eyeargraduate', 	'value' => $eyeargraduate, 	'id' => 'fee_name');
				$ssnAttrib = 	array('name' => 'sschoolname', 		'value' => $sschoolname, 	'id' => 'fee_name');
				$ssaAttrib = 	array('name' => 'sschooladdress', 	'value' => $sschooladdress, 'id' => 'fee_name');
				$sygAttrib = 	array('name' => 'syeargraduate', 	'value' => $syeargraduate, 	'id' => 'fee_name');
				$vsnAttrib = 	array('name' => 'vschoolname', 		'value' => $vschoolname, 	'id' => 'fee_name');
				$vsaAttrib = 	array('name' => 'vschooladdress', 	'value' => $vschooladdress, 'id' => 'fee_name');
				$vygAttrib = 	array('name' => 'vyeargraduate', 	'value' => $vyeargraduate, 	'id' => 'fee_name');
				$tsnAttrib = 	array('name' => 'tschoolname', 		'value' => $tschoolname, 	'id' => 'fee_name');
				$tsaAttrib = 	array('name' => 'tschooladdress', 	'value' => $tschooladdress, 'id' => 'fee_name');
				$tygAttrib = 	array('name' => 'tyeargraduate', 	'value' => $tyeargraduate, 	'id' => 'fee_name');
				$osnAttrib = 	array('name' => 'oschoolname', 		'value' => $oschoolname, 	'id' => 'fee_name');
				$osaAttrib = 	array('name' => 'oschooladdress', 	'value' => $oschooladdress, 'id' => 'fee_name');
				$oygAttrib = 	array('name' => 'oyeargraduate', 	'value' => $oyeargraduate, 	'id' => 'fee_name');				
				
				$fathernameAttrib = 	array('name' => 'fathername', 		'value' => $fathername, 	  'id' => 'fee_name');
				$fathercontactAttrib = 	array('name' => 'fathercontact', 	'value' => $fathercontact, 	  'id' => 'fee_name');
				$fatheroccupAttrib = 	array('name' => 'fatheroccupation', 'value' => $fatheroccupation, 'id' => 'fee_name');
				$mothernameAttrib = 	array('name' => 'mothername', 		'value' => $mothername, 	  'id' => 'fee_name');
				$mothercontactAttrib = 	array('name' => 'mothercontact', 	'value' => $mothercontact, 	  'id' => 'fee_name');
				$motheroccupAttrib = 	array('name' => 'motheroccupation', 'value' => $motheroccupation, 'id' => 'fee_name');
				$parentaddressAttrib = 	array('name' => 'parentaddress', 	'value' => $parentaddress, 	  'id' => 'fee_name');
				
				$guardnameAttrib = 		array('name' => 'guardianname', '	value' => $nameofguardian, 	'id' => 'guardianname');
				$guardcontactAttrib = 	array('name' => 'guardiancontact', 'value' => $guardiancontact, 'id' => 'fee_name');
				$guardaddressAttrib = 	array('name' => 'guardianaddress', 'value' => $guardianaddress, 'id' => 'fee_name');
				
				/* other form attrib */
				$useridHiidenAttrib = array('user_id' => $db_entry->user_id);
				$checked = $this->session->userdata('checkbox_checked') == TRUE ? 'checked' : NULL;
				$cancel_edit = md5(strtolower('cancel'));
				$gender_dropdown = array('Male'=> 'Male','Female' => 'Female');
				$civilstat_dropdown = array('Single'=> 'Single','Married' => 'Married','Divorced'=>'Divorced');
				$disabled = 'class="dropdown"';
				
				// get usertype and use to choose controller
				$usertype = strtolower($this->session->userdata('usertype')); 
				// FORM OPEN
				switch($usertype){
					case $usertype == 'student':
						$link = $usertype.'/profile/';
						echo form_open($usertype.'/post_edit_student_profile',$formAttrib);
					break;
					case $usertype == 'admin':
						$link = $usertype.'/update_student_data/';
						echo form_open($usertype.'/post_edit_student_profile',$formAttrib);
					break;
				}
				
			?>
				<div class="profile-block">
				<fieldset style="width:180px;">
				<legend>Edit Profile</legend>
				<input type="checkbox" id="enable_edit" <?=$checked;?>/> Enable Edit Profile
				</fieldset>
					<table>
						<thead>
							<caption><h6>User Profile</h6></caption>
							<th class ="profile_name"></th>
						</thead>
						<tbody class="">
							<tr><td>Firstname :			</td><td><?echo form_input($firstnameAttrib);?>		</td><td><?echo form_error('firstname');?>		</td></tr>
							<tr><td>Middlename :		</td><td><?echo form_input($middlenameAttrib);?>	</td><td><?echo form_error('middlename');?>		</td></tr>
							<tr><td>Lastname :			</td><td><?echo form_input($lastnameAttrib);?>		</td> <td><?echo form_error('lastname');?>		</td></tr>
							<tr><td>Gender :			</td><td><?echo form_dropdown('gender',$gender_dropdown,$gender,$disabled);?>		</td><td><?echo form_error('gender');?>			</td></tr>
							<tr><td>Civil Status :		</td><td><?echo form_dropdown('civilstatus',$civilstat_dropdown,$civilstatus,$disabled);?>	</td><td><?echo form_error('civilstatus');?>	</td></tr>
							<tr><td>Age :				</td><td><?echo form_input($ageAttrib);?>			</td><td><?echo form_error('age');?>			</td></tr>
							<tr><td>Birth date :		</td><td><?echo form_input($dobAttrib);?>			</td><td><?echo form_error('dob');?>			</td></tr>
							<tr><td>Birth place :		</td><td><?echo form_input($pobAttrib);?>			</td><td><?echo form_error('pob');?>			</td></tr>
							<tr><td>Disability :		</td><td><?echo form_input($disabilityAttrib);?>	</td><td><?echo form_error('disability');?>		</td></tr>
							<tr><td>Nationality :		</td><td><?echo form_input($nationalityAttrib);?>	</td><td><?echo form_error('nationality');?>	</td></tr>
							<tr><td>Religion :			</td><td><?echo form_input($religionAttrib);?>		</td><td><?echo form_error('religion');?>		</td></tr>
							<tr><td>Contact Number :	</td><td><?echo form_input($contactnumberAttrib);?>	</td><td><?echo form_error('contactnumber');?>	</td></tr>
							<tr><td>Email Address :		</td><td><?echo form_input($emailAttrib);?>			</td><td><?echo form_error('email');?>			</td></tr>
							<tr><td>Present Address :	</td><td><?echo form_input($presentaddressAttrib);?></td><td><?echo form_error('presentaddress');?>	</td></tr>
						</tbody>
					</table>
				</div>
				
				<div class="profile-block">
					<table>
						<thead>
							<caption><h6>Educ. Background</h6></caption>
							<th class ="profile_name"></th>
						</thead>
						<tbody class="">
									<tr><td><p class="title">Elementary</p></td></tr>
									<tr><td>School Name :	</td><td><?echo form_input($esnAttrib);?></td><td><?form_error('eschoolname')?>		</td></tr>
									<tr><td>Address :		</td><td><?echo form_input($esaAttrib);?></td><td><?form_error('eschooladdress')?>	</td></tr>
									<tr><td>Year Graduated :</td><td><?echo form_input($eygAttrib);?></td><td><?form_error('eyeargraduate')?>	</td></tr>
									
									<tr><td><p class="title">Secondary</p></td></tr>
									<tr><td>School Name :	</td><td><?echo form_input($ssnAttrib);?></td><td><?form_error('sschoolname')?>		</td></tr>
									<tr><td>Address :		</td><td><?echo form_input($ssaAttrib);?></td><td><?form_error('sschooladdress')?>	</td></tr>
									<tr><td>Year Graduated :</td><td><?echo form_input($sygAttrib);?></td><td><?form_error('syeargraduate')?>	</td></tr>
									
									<tr><td><p class="title">Vocational</p></td></tr>
									<tr><td>School Name :	</td><td><?echo form_input($vsnAttrib);?></td><td><?form_error('vschoolname')?>		</td></tr>
									<tr><td>Address :		</td><td><?echo form_input($vsaAttrib);?></td><td><?form_error('vschooladdress')?>	</td></tr>
									<tr><td>Year Graduated :</td><td><?echo form_input($vygAttrib);?></td><td><?form_error('vyeargraduate')?>	</td></tr>
									
									<tr><td><p class="title">Tertiary</p></td></tr>
									<tr><td>School Name :	</td><td><?echo form_input($tsnAttrib);?></td><td><?form_error('tschoolname')?>		</td></tr>
									<tr><td>Address :		</td><td><?echo form_input($tsaAttrib);?></td><td><?form_error('tschooladdress')?>	</td></tr>
									<tr><td>Year Graduated :</td><td><?echo form_input($tygAttrib);?></td><td><?form_error('tyeargraduate')?>	</td></tr>
									
									<tr><td><p class="title">Others</p></td></tr>
									<tr><td>School Name :	</td><td><?echo form_input($osnAttrib);?></td><td><?form_error('oschoolname')?>		</td></tr>
									<tr><td>Address :		</td><td><?echo form_input($osaAttrib);?></td><td><?form_error('oschooladdress')?>	</td></tr>
									<tr><td>Year Graduated :</td><td><?echo form_input($oygAttrib);?></td><td><?form_error('oyeargraduate')?>	</td></tr>
						</tbody>
					</table>
				</div>
				
				<div class="profile-block">
					<table>
						<thead>
							<caption><h6>Family Background</h6></caption>
							<th class ="profile_name"></th>
						</thead>
						<tbody class="">
							<tr><td>Father's name :			</td><td><?echo form_input($fathernameAttrib);?>   </td><td><? echo form_error('fathername');?>		 </td></tr>
							<tr><td>Father's Occupation :	</td><td><?echo form_input($fatheroccupAttrib);?>  </td><td><? echo form_error('fatheroccupation');?></td></tr>
							<tr><td>Father's COntact # :	</td><td><?echo form_input($fathercontactAttrib);?></td><td><? echo form_error('fathercontact');?>	 </td></tr>
							<tr><td>Mother's name :			</td><td><?echo form_input($mothernameAttrib);?>   </td><td><? echo form_error('mothername');?>		 </td></tr>
							<tr><td>Mother's Occupation :	</td><td><?echo form_input($motheroccupAttrib);?>  </td><td><? echo form_error('motheroccupation');?></td></tr>
							<tr><td>Mother's COntact # :	</td><td><?echo form_input($mothercontactAttrib);?></td><td><? echo form_error('mothercontact');?>	 </td></tr>
							<tr><td>Parent's Address :		</td><td><?echo form_input($parentaddressAttrib);?></td><td><? echo form_error('parentaddress');?>	 </td></tr>
						</tbody>
					</table>
				</div>
				
				<div class="profile-block">
					<table>
						<thead>
							<caption><h6>Guardians Profile</h6></caption>
							<th class ="profile_name"></th>
						</thead>
						<tbody class="">

							<tr><td>Guardian's Name :		</td><td><input type="text" name='guardianname' id ='guardianname' value="<?=$nameofguardian;?>">	  </td><td><?echo form_error('guardianname');?>	 </td></tr>
							<tr><td>Guardian's Address :	</td><td><?echo form_input($guardaddressAttrib);?></td><td><?echo form_error('guardiancontact');?></td></tr>
							<tr><td>Guardian's Contact # :	</td><td><?echo form_input($guardcontactAttrib);?></td><td><?echo form_error('guardianaddress');?></td></tr>
						</tbody>
					</table>
				</div>
				<div class="input-block ">
					<? echo form_hidden($useridHiidenAttrib);?>
					<? echo form_submit($submitButtonAttrib);?>
					<a href="<?echo site_url($link).'/'.$db_entry->user_id.'/'.$cancel_edit;?>" class="btn">Cancel</a>
				</div>
				</form>
			<?php endforeach?>
<?else:?>
	<div class="notice">User Profile data does not exist</div>
<?endif;?>
		</div>
    </div>
    
    <div class="inner-border">
    
 
    
    <?php if(!empty($db_entries2)): ?>
	<h6>Approved Subjects (<?php echo count($db_entries2) ?>) </h6>	
    	<table>
		<thead>
			<th class="level">Subject Name</th>
		</thead>

        <tbody>
            <?php foreach($db_entries2 as $db_entry): ?>
                <tr><td><?php echo $db_entry->subject_name; ?></td></tr>
            <?php endforeach ?>
        </tbody>
        </table>
        
	<?php else: ?>
    	<h6>Approved Subjects</h6>
    	<div class="notice">No subjects approved yet</div>
    	
	<?php endif;?>
    
    </div>
</div>
<script type="text/javascript" src="<?php echo base_url()?>assets/script/student_profile.js"></script>

